<?php

namespace App\Dao;


use App\Model\AnchorVideoZan;
use Hyperf\Context\ApplicationContext;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Request;

class AnchorVideoZanDao
{
    #[Inject]
    public Request $request;
    private static $instance;

    public static function getInstance()
    {
        if (!self::$instance) {
            self::$instance = Applicationcontext::getcontainer()->get(self::class);
        }
        return self::$instance;
    }

    /**
     * 获取视频点赞数
     * @param $videoId
     * @return mixed
     */
    public function zanCount($videoId)
    {
        return AnchorVideoZan::query()->where('video_id', $videoId)->count();
    }

    /**
     * 是否点赞
     * @param int $uid 用户id
     * @param $videoId
     * @return int
     */
    public function isZan($uid, $videoId)
    {
        return AnchorVideoZan::query()->where('uid', $uid)->where('video_id', $videoId)->exists();


    }


}